package bjut.core.proxy;

import bjut.core.aop.AdvisedSupport;

/**
 * @Author: zhuzhiming
 * @Date: 2022/6/15 13:17
 */
public class ProxyFactory {

    private AdvisedSupport advised;

    public ProxyFactory(AdvisedSupport advised) {
        this.advised = advised;
    }

    public Object getProxy(){
        return createAopProxy().getProxy();
    }

    private AopProxy createAopProxy(){

        if(advised.isProxyTargetClass()){
            return new Cglib2AopProxy(advised);
        }

        return new JdkDynamicAopProxy(advised);

    }

}
